package com.xiangxiao.rpan.file.consumer;

import com.alibaba.fastjson.JSONObject;
import com.xiangxiao.rpan.file.config.MultipartSupportConfig;
import com.xiangxiao.rpan.file.consumer.callback.StorageClientCall;
import com.xiangxiao.rpan.file.dto.FileQueryDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/12/26 17:37
 */
@FeignClient(value = "rpan-storage", fallback = StorageClientCall.class, configuration = MultipartSupportConfig.class)
public interface IConsumerStorageClient {
  @PostMapping("/api/storage/files")
  JSONObject getFiles(@RequestBody FileQueryDto fileQueryDto);

  @PostMapping(value = "/api/file/operator/upload/file", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
  JSONObject bigFileUploadMulti(@RequestPart("file") MultipartFile file,
                                @RequestParam("fileMD5") String fileMD5, @RequestParam("fileSize") Long fileSize,
                                @RequestParam("totalChunks") int totalChunks, @RequestParam("currChunks") int currChunks);
}
